<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <%@ page contentType="text/html;charset=UTF-8" language="java" pageEncoding="UTF-8" %>
    <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
    <%@taglib uri="/struts-tags" prefix="s" %>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>media</title>
    <link rel="stylesheet" type="text/css" href="../resource/css/screen.css"/>
    <link href="${pageContext.request.contextPath}/resource/css/uploadify.css"
          rel="stylesheet" type="text/css"/>
    <script type="text/javascript" src="${pageContext.request.contextPath}/resource/js/jquery-1.4.2.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/resource/js/swfobject.js"></script>
    <script type="text/javascript"
            src="${pageContext.request.contextPath}/resource/js/jquery.uploadify.v2.1.0.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/resource/js/upload.js"></script>
</head>
<body>
<div class="wrap">
    <div class="header">
        <div class="logo">
            <a href="#"><img alt="logo" src="../resource/images/brand.gif"/></a>
        </div>
        <ul id="nav">
            <li class="nav_image nav_current"><a title="picture" href="${pageContext.request.contextPath}/sz/pictureTab.action"><img alt="picture"
                                                                               src="../resource/images/image.gif"/></a>
            </li>
            <li class="nav_video"><a title="video" href="${pageContext.request.contextPath}/sz/videoTab.action"><img alt="video" src="../resource/images/video.gif"/></a>
            </li>
            <li class="nav_audio"><a title="audio" href="${pageContext.request.contextPath}/sz/audioTab.action"><img alt="audio" src="../resource/images/audio.gif"/></a>
            </li>
            <li class="nav_model"><a title="model" href="${pageContext.request.contextPath}/sz/modelTab.action"><img alt="model" src="../resource/images/model.gif"/></a>
            </li>
            <li class="nav_action"><a title="activity" href="${pageContext.request.contextPath}/sz/activityTab.action"><img alt="activity"
                                                                     src="../resource/images/action.gif"/></a></li>
        </ul>

        <div id="content">

            <form id="key_form" method="get" style="display:none;" target="upload_target"
                  action="${pageContext.request.contextPath}/sz/pictureNameSearch.action">
                <div class="inputbox">
                    <div class="input_radio">
                        <p>
                            <input type="radio" id="to_con" name="content"/>
                            <label for="radio_c1">内容搜索</label>
                        </p>

                        <p>
                            <input type="radio" name="content" checked="checked"/>
                            <label for="radio_i1">关键字搜索</label>
                        </p>
                    </div>
                </div>
                <div class="key_search">
                    <input class="key_t" name="picture.title" type="text"/>
                    <input class="key_b" value="" type="submit"/>
                </div>
                <div style="clear:both;"></div>
            </form>
            <form id="content_form" style="" method="post" target="upload_target"
                  action="${pageContext.request.contextPath}/sz/uploadTempicture.action" enctype="multipart/form-data">
                <div class="inputbox">
                    <div class="input_radio">
                        <p>
                            <input type="radio" name="content" checked="checked"/>
                            <label for="radio_c1">内容搜索</label>
                        </p>

                        <p>
                            <input type="radio" name="content" id="to_key"/>
                            <label for="radio_i1">关键字搜索</label>
                        </p>

                    </div>
                </div>
                <div class="key_search">
                    <p style="font-size:12px; height:32px; overflow:hidden; position:absolute;">
                        <input id="files" style="height:32px;" size="30" name="files" type="file"/>
                        <input class="key_b" style="z-index:1000;margin-left:35px;" type="submit" value=""/>
                    </p>

                    <div style="clear:both;"></div>
                </div>
            </form>

        </div>
    </div>
    <div class="content">
        <div class="sidebar">
            <img src="../resource/images/pic_top.gif" alt="图片分类列表"/>
            <ul id="pictureType">
                <c:forEach var="pictureTypes" items="${types}">
                    <li title="${pictureTypes.typeId }">
                        <a alt="${pictureTypes.server}-${pictureTypes.name}" class="side_list"
                           href="#">${pictureTypes.server}-<br/>${pictureTypes.name}</a>
                        <a class="side_del" title="${pictureTypes.typeId}" href="#"><img alt="delete"
                                                                                         src="../resource/images/cha.gif"/></a>
                    </li>
                </c:forEach>
            </ul>
        </div>

        <div class="main">
            <c:forEach var="top" items="${resultSet.list}">
                <div class="show_box">
                    <a class="show_img"
                       href="${pageContext.request.contextPath}/sz/pictureDetail.action?picture.id=${top.id}"
                       target="_blank"><img alt="img"
                                            src="${top.minPictureUrl}"/></a>

                    <p>
                        <a href="${pageContext.request.contextPath}/sz/pictureDetail.action?picture.pictureId=${top.id}">${top.title}</a>
                    </p>

                    <p><span>${top.server}</span> <span>${top.typeName}</span></p>

                    <p><span class="img_size">${top.disrate}</span>
                        <span class="img_type">${top.fileType}</span>
                        <span class="img_b">${top.size}KB</span></p>
                </div>
            </c:forEach>
            <div class="clear"></div>
        </div>
    </div>

    <div class="pages">
        <div id="search_con">
            <input type="hidden" name="actionName"
                   value="${pageContext.request.contextPath}/sz/${resultSet.actionName}.action">
            <input type="hidden" name="type" value="${resultSet.type}">
            <input type="hidden" name="keyWord" value="${resultSet.keyWords}">
            <input type="hidden" name="idList" value="${resultSet.idList}">
            <c:choose>
                <c:when test="${!empty resultSet.pageInfo.currentPage}">
                    <input type="hidden" name="currentPage" value="${resultSet.pageInfo.currentPage}">
                </c:when>
                <c:otherwise>
                    <input type="hidden" name="currentPage" value="0">
                </c:otherwise>
            </c:choose>
            <c:choose>
                <c:when test="${!empty resultSet.pageInfo.totalPage}">
                    <input type="hidden" name="totalPage" value="${resultSet.pageInfo.totalPage}">
                    <p id="pages_num" class="pages_num">
                <a class="point" href=""><img alt="previousPages" src="../resource/images/prepoint_l.gif"/></a>
             <span>
             </span>
                <a class="point" href=""><img alt="forwardPages" src="../resource/images/prepoint_r.gif"/></a>
            </p>

            <p class="pages_sum">
                Pages:<span>${resultSet.pageInfo.currentPage}</span>&#47;<span>${resultSet.pageInfo.totalPage}</span>
            </p>
                </c:when>
                <c:otherwise>
                    <input type="hidden" name="totalPage" value="0">
                </c:otherwise>
            </c:choose>
            <input type="hidden" name="searchId" value="${searchId}">


        </div>
    </div>

    <div class="footer">
        <span>&copy;</span><span>电子科技大学数字媒体技术研究所</span><span>All rights reserved</span>
        <span>&#124;</span><span>Powered by Dreamfly</span>
    </div>
</div>
<script type="text/javascript" src="${pageContext.request.contextPath}/resource/js/top_nav.js"></script>
<script type="text/javascript">
    $(document).ready(function() {
        var $search_con = $("#search_con");
        var url = $search_con.find("input[name=actionName]").val();
        var keyWord = $search_con.find("input[name=keyWord]").val();
        var ids = $search_con.find("input[name=idList]").val();
        var current_i = $("input[name=currentPage]").val();
        var totalPage = $("input[name=totalPage]").val();
        var now_type = $("input[name=type]").val();
        var pageFlag,queryname,searchId;
        if (url.indexOf('Content') != -1) {
            pageFlag = "clientPage";
            queryname = "fileName"
            searchId = $("input[name=searchId]").val();
        } else {
            pageFlag = "page";
            queryname = now_type.toLowerCase() + ".title"
        }
        if (ids) {
            ids = ids.replace(/,/g, "&szTypeIds=");
        }
        var numIndex = [];
        if (parseInt(totalPage) <= 5) {
            var indexFlag = parseInt(totalPage);
            for (var i = 0; i < indexFlag; i++) {
                numIndex.unshift(indexFlag - i);
            }
        } else if (parseInt(current_i) <= 3) {
            numIndex = numIndex.concat(1, 2, 3, 4, 5);
        } else if (parseInt(current_i) + 2 >= totalPage) {
            var indexFlag = parseInt(totalPage);
            numIndex = numIndex.concat(indexFlag - 4, indexFlag - 3, indexFlag - 2, indexFlag - 1, indexFlag);
        } else {
            var indexFlag = parseInt(current_i);
            numIndex = numIndex.concat(indexFlag - 2, indexFlag - 1, indexFlag, indexFlag + 1, indexFlag + 2);
        }
        var docFra = document.createDocumentFragment();
        for (var i = 0; i < numIndex.length; i++) {
            var in_a = document.createElement("a");
            in_a.href = url + "?" + pageFlag + "=" + numIndex[i] + "&" + queryname + "=" + keyWord;
            in_a.innerHTML = numIndex[i];
            if (searchId) {
                in_a.href += "&searchId=" + searchId;
            }
            if (ids) {
                in_a.href += "&szTypeIds=" + ids;
            }
            if (numIndex[i] == current_i) {
                $(in_a).addClass("current");
            }
            docFra.appendChild(in_a);
        }
        document.getElementById("pages_num").getElementsByTagName("span")[0].appendChild(docFra);
        $("#pages_num a.point").each(function(i) {
            if (i == 0) {
                this.href = url + "?" + pageFlag + "=" + numIndex[0] + "&" + queryname + "=" + keyWord;
                if (ids) {
                    this.href += "&szTypeIds=" + ids;
                }
                if (searchId) {
                    this.href += "&searchId=" + searchId;
                }
            } else {
                this.href = url + "?" + pageFlag + "=" + numIndex[numIndex.length - 1] + "&" + queryname + "=" + keyWord;
                if (ids) {
                    this.href += "&szTypeIds=" + ids;
                }
                if (searchId) {
                    this.href += "&searchId=" + searchId;
                }
            }
        });
    });
    /*$(document).ready(function() {//for change img src
        $("div.show_box").each(function() {
            var $img = $(this).find("img");
            var url = $img.attr("src");
            $.ajax({
                type:"GET",
                url:url,
                dataType:"text",
                success:function(data) {
                    $img.attr("src", data);
                },
                error:function(){
                	$img.attr("src","error");
                }
            });
        });
    });*/
</script>
</body>
</html>
